﻿using CRM.Infrastructure.Dto.Request.Customer;
using CRM.Infrastructure.Dto.Response.Customer;
using CRM.Infrastructure.Dto.Response.Vip;
using CRM.Service.Interface;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace CRM.Api.Admin.Controllers
{
    public class CustomerVipController : BaseController
        
    {
        
        private readonly I_CustomerVip_Service _customervip_Service;
        private readonly I_Login_Service _login_Service;
        public CustomerVipController(I_Login_Service login_Service, I_CustomerVip_Service customervip_Service) : base(login_Service)
        {
            _customervip_Service = customervip_Service;
            _login_Service=login_Service;
        }
        /// <summary>
        /// 等级下拉框
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpGet]

        public async Task<IActionResult> Get_Level()
        {
            var result = await _customervip_Service.Get_Level();
            return Ok(result);
        }
        /// <summary>
        /// 获取所有会员
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpGet]

        public async Task<IActionResult> Get_vip()
        {
 
            var result = await _customervip_Service.Get_vip();
            return Ok(result);
        }
        /// <summary>
        /// 获取单个会员
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> Get_vip_single(string id)
        {
            var result = await _customervip_Service.Get_vip_single(id);
            return Ok(result);
        }
        /// <summary>
        /// 获取会员订单
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpGet]

        public async Task<IActionResult> Get_vip_Order(string? id)
        {
            var result = await _customervip_Service.Get_vip_Order(id);
            return Ok(result);
        }
        /// <summary>
        /// 获取会员信息
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpGet]

        public async Task<IActionResult> Get_vip_Tolist()
        {
            var result = await _customervip_Service.Get_vip_Tolist();
            return Ok(result);
        }

        /// <summary>
        /// 修改会员等级配置
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]

        public async Task<IActionResult> update_vip(Dictionary_Vip_Response_Dto dto)
        {
            var result = await _customervip_Service.update_vip(dto);
            return Ok(result);
        }
        /// <summary>
        /// 会员消费
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpGet]

        public async Task<IActionResult> Vip_Consumption()
        {
            var user = await this.Get_Curr_User();
            var result = await _customervip_Service.Vip_Consumption(user.UId);
            return Ok(result);
        }
        /// <summary>
        /// 新增会员
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]

        public async Task<IActionResult> Add_vip(Vip_Request_Dto dto)
        {
            var result = await _customervip_Service.Add_vip(dto);
            return Ok(result);
        }
        /// <summary>
        /// 删除会员
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]

        public async Task<IActionResult> Del_vip(string id)
        {
            var result = await _customervip_Service.Del_vip(id);
            return Ok(result);
        }
        /// <summary>
        /// 给会员充值
        /// </summary>
        /// <param name="id"></param>
        /// <param name="money"></param>
        /// <param name="desc"></param>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]

        public async Task<IActionResult> Recharge_vip(string id, decimal money,string? desc)
        {
            var result = await _customervip_Service.Recharge_vip(id, money, desc);
            return Ok(result);
        }
    }
}
